using MediatR;
using RBAC.ErrorCode;
using SmartHealthcare.Read.Api.DTo;

namespace SmartHealthcare.Read.Api.Application.Command.Medicine
{
    /// <summary>
    /// 药物智能搜索命令
    /// </summary>
    public class SearchMedicineCommand : IRequest<APIResult<List<MedicineSearchDto>>>
    {
        /// <summary>
        /// 药物名称（支持模糊搜索）
        /// </summary>
        public string? MedicineName { get; set; }

        /// <summary>
        /// 药物编码（支持模糊搜索）
        /// </summary>
        public string? MedicineCode { get; set; }

        /// <summary>
        /// 药物类型
        /// </summary>
        public string? MedicineType { get; set; }

        /// <summary>
        /// 生产厂家（支持模糊搜索）
        /// </summary>
        public string? Manufacturer { get; set; }

        /// <summary>
        /// 药物状态（0:停用 1:正常）
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 验证参数
        /// </summary>
        /// <returns></returns>
        public bool IsValid()
        {
            // 至少需要提供一个搜索条件
            return !string.IsNullOrWhiteSpace(MedicineName) 
                || !string.IsNullOrWhiteSpace(MedicineCode) 
                || !string.IsNullOrWhiteSpace(MedicineType) 
                || !string.IsNullOrWhiteSpace(Manufacturer) 
                || Status.HasValue;
        }

        /// <summary>
        /// 检查是否有搜索参数
        /// </summary>
        /// <returns></returns>
        public bool HasSearchParameters()
        {
            return !string.IsNullOrWhiteSpace(MedicineName) 
                || !string.IsNullOrWhiteSpace(MedicineCode) 
                || !string.IsNullOrWhiteSpace(MedicineType) 
                || !string.IsNullOrWhiteSpace(Manufacturer) 
                || Status.HasValue;
        }
    }
} 